/**
 * Advanced Software Engineering (monica Farrow)
 * JUnit CalculateFeeTest class
 * 
 * Some of the methods in this class have been based on lecture notes provided by
 * Monica Farrow as a part of Software Engineering courses at Heriot-Watt University.
 */

package depotTests;

import static org.junit.Assert.*;

import org.junit.Test;
import depot.*;
import depotModels.*;

public class CalculateFeeTest {

	private int[] dim1;
	private Parcel pcl;
	private CustomerProcessing cp;

	/**
	 * STAGE 1
	 * Test valid parcel type returned
	 * Test type = E
	 * (calculateFee altered to return String)
	 */
	/*	@Test
	public final void testCalcFeePclType() {
		// create Parcel to test
		dim1 = new int[] {35,35,35};
		pcl = new Parcel("E000112", dim1, 2.55, 2);
		// create DepotManager object to access calculateFee
		DepotManager dm = new DepotManager();

		String expected1 = "E";
		String message1 = "Failed for E000112";
		String actual1 = dm.calculateFee(pcl);
		assertEquals(message1, expected1, actual1);
	} */

	/**
	 * STAGE 2 -  testing volume fee
	 * Test return of volume fee, ensuring other fees remain constant:
	 * basic fee (1), days in depot fee (0), discount (0)
	 * (calculateFee altered to return Double)
	 */
	@Test
	public final void testCalcFeeVol() {

		// Test 1 - just under 28000
		// create Parcel to test
		dim1 = new int[] {30,30,31};
		pcl = new Parcel("E000112", dim1, 2.55, 1);
		// create CustomerProcessing object to access calculateFee
		cp = new CustomerProcessing();

		Double expected1 = 1.0;
		String message1 = "Failed for vol 27900";
		Double actual1 = cp.calculateFee(pcl);
		assertEquals(message1, expected1, actual1);

		// Test 2 - just over 28000
		// create Parcel to test
		dim1 = new int[] {25,25,45};
		pcl = new Parcel("E000112", dim1, 2.55, 1);

		Double expected2 = 2.0;
		String message2 = "Failed for vol 28125";
		Double actual2 = cp.calculateFee(pcl);
		assertEquals(message2, expected2, actual2);

		// Test 3 - exactly 28000
		// create Parcel to test
		dim1 = new int[] {280,10,10};
		pcl = new Parcel("E000112", dim1, 2.55, 1);

		Double expected3 = 2.0;
		String message3 = "Failed for vol 28000";
		Double actual3 = cp.calculateFee(pcl);
		assertEquals(message3, expected3, actual3);

		// Test 4 - exactly 56000
		// create Parcel to test
		dim1 = new int[] {40,40,35};
		pcl = new Parcel("E000112", dim1, 2.55, 1);

		Double expected4 = 3.0;
		String message4 = "Failed for vol 56000";
		Double actual4 = cp.calculateFee(pcl);
		assertEquals(message4, expected4, actual4);

		// Test 5 - exactly 216000
		// create Parcel to test
		dim1 = new int[] {60,60,60};
		pcl = new Parcel("E000112", dim1, 2.55, 1);

		Double expected5 = 8.0;
		String message5 = "Failed for vol 216000";
		Double actual5 = cp.calculateFee(pcl);
		assertEquals(message5, expected5, actual5);
	}

	/**
	 * STAGE 3 - testing days in depot fee
	 * Test return days in depot fee, ensuring other fees remain constant:
	 * basic fee (1), volume fee (0), discount (0)
	 */
	@Test
	public final void testCalcFeeDays() {

		// Test 1 - days = 1
		// create Parcel to test
		dim1 = new int[] {10,10,10};
		pcl = new Parcel("E000112", dim1, 2.55, 1);
		// create CustomerProcessing object to access calculateFee
		cp = new CustomerProcessing();

		Double expected1 = 1.0;
		String message1 = "Failed for days = 1";
		Double actual1 = cp.calculateFee(pcl);
		assertEquals(message1, expected1, actual1);

		// Test 2 - days = 2
		// create Parcel to test
		dim1 = new int[] {10,10,10};
		pcl = new Parcel("E000112", dim1, 2.55, 2);

		Double expected2 = 2.0;
		String message2 = "Failed for days = 2";
		Double actual2 = cp.calculateFee(pcl);
		assertEquals(message2, expected2, actual2);

		// Test 3 - days = 8
		// create Parcel to test
		dim1 = new int[] {10,10,10};
		pcl = new Parcel("E000112", dim1, 2.55, 8);

		Double expected3 = 8.0;
		String message3 = "Failed for days = 8";
		Double actual3 = cp.calculateFee(pcl);
		assertEquals(message3, expected3, actual3);

	}

	/**
	 * STAGE 4 - testing parcel type discount
	 * Test return of discount, ensuring other fees remain constant:
	 * basic fee (1), volume fee (0), days in depot fee (0)
	 */
	@Test
	public final void testCalcFeeDiscount() {

		// Test 1 - parcel type = E
		// create Parcel to test
		dim1 = new int[] {10,10,10};
		pcl = new Parcel("E000112", dim1, 2.55, 1);
		// create CustomerProcessing object to access calculateFee
		cp = new CustomerProcessing();

		Double expected1 = 1.0;
		String message1 = "Failed for parcel type = E";
		Double actual1 = cp.calculateFee(pcl);
		assertEquals(message1, expected1, actual1);

		// Test 2 - parcel type = S
		// create Parcel to test
		dim1 = new int[] {10,10,10};
		pcl = new Parcel("S000112", dim1, 2.55, 1);

		Double expected2 = 0.9;
		String message2 = "Failed for parcel type = S";
		Double actual2 = cp.calculateFee(pcl);
		assertEquals(message2, expected2, actual2);

		// Test 3 - parcel type = X
		// create Parcel to test
		dim1 = new int[] {10,10,10};
		pcl = new Parcel("X000112", dim1, 2.55, 1);

		Double expected3 = 0.8;
		String message3 = "Failed for parcel type = X";
		Double actual3 = cp.calculateFee(pcl);
		assertEquals(message3, expected3, actual3);

	}

}
